package com.youhong.teethcare.utils;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.content.Context;

/**
 * Created by Administrator on 2018/5/11 0011.
 */

public class BTUtils {

    public static boolean isBluetoothConnected(BluetoothDevice device, Context context) {

        BluetoothManager manager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
        BluetoothAdapter mBluetoothAdapter = manager.getAdapter();

        if (mBluetoothAdapter == null ||
                (manager.getConnectionState(device, BluetoothProfile.GATT) == BluetoothProfile.STATE_DISCONNECTED
                       /* && manager.getConnectionState(device, BluetoothProfile.A2DP) == BluetoothProfile.STATE_DISCONNECTED*/
                )
                ) {
           /* Utils.logDebug(TAG, "GATT_SERVER " + mBluetoothAdapter.getProfileConnectionState(BluetoothProfile.GATT_SERVER));
            Utils.logDebug(TAG, "GATT " + mBluetoothAdapter.getProfileConnectionState(BluetoothProfile.GATT));*/
            return false;
        }
        return true;
    }
}
